package Service.impl;

import Dao.AttendanceDao;
import Dao.impl.AttendanceDaoImpl;
import Domin.Attendance;
import Service.AttendanceService;

import java.time.LocalDate;
import java.util.List;

public class AttendanceServiceImpl implements AttendanceService {
    private final AttendanceDao attendanceDao = new AttendanceDaoImpl();

    @Override
    public boolean markAttendance(int empId, LocalDate date, String status) {
        Attendance a = new Attendance(empId, date, status);
        return attendanceDao.recordAttendance(a);
    }

    @Override
    public List<Attendance> viewMyAttendance(int empId) {
        return attendanceDao.getAttendanceByEmpId(empId);
    }

    @Override
    public List<Attendance> viewAllAttendance() {
        // 简化：返回所有记录（实际可分页）
        return attendanceDao.getAttendanceByDate(LocalDate.now().minusDays(30)); // 近30天
    }

    @Override
    public List<Attendance> viewAttendanceByDate(LocalDate date) {
        return attendanceDao.getAttendanceByDate(date);
    }
}